﻿using MediatR;
using T_Person.APi.Applation.CommandHandlers.EmployeeHandlers;
using T_Person.BaseRep.Interface;

namespace T_Person.APi.Applation.Commands.EmployeeCommand
{
    public class EmployeeUpdateStateByidCommand : IRequestHandler<EmployeeUpdateStateByidHandlers, int>
    {
        private readonly IEmployeeRep employeeRep;

        public EmployeeUpdateStateByidCommand(IEmployeeRep employeeRep)
        {
            this.employeeRep = employeeRep;
        }

        public async Task<int> Handle(EmployeeUpdateStateByidHandlers request, CancellationToken cancellationToken)
        {
            var list =await employeeRep.GetAloneByid(request.id);
            list.EmployeeStyle=request.state;
            list.UpdateDate=DateTime.Now;
            list.UpdateBy = "小红";
            return await employeeRep.Update(list);
        }
    }
}
